<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>合伙人列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../module/inventory/css/admin/index.css" />
<link href="../admin/easyui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../script/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">

$(function(){
	$('#tarento').treegrid({
		fitColumns:true,
		idField:"id",
		treeField:"name",
		url:'<{$config.weburl}>/admin/module.php?m=product&s=tarento_list.php&act=ajax_get_tarento&member_id=<{$smarty.get.member_id}>',
		columns:[[
                    {title:'ID',field:'id',width:180,hidden:true},
                    {title:'用户ID',field:'member_id',width:100},
                    {title:'会员名称',field:'name',width:250},
                    {title:'手机',field:'mobile',width:180},
                    {title:'团队人数',field:'member_num',width:180},
                    {title:'本月销售额',field:'self_sales',width:180},
                    {title:'团队本月销售额',field:'group_sales',width:180},
                    {title:'邀请码',field:'invite_code',width:180},
                    {title:'合伙人积分',field:'extra_point',width:180},
                    {title:'QQ',field:'qq',width:180},
                    {title:'微信',field:'weixin',width:180},
                    {title:'最低返利比例',field:'lowest_rate',width:180},
                    {title:'',field:'view',width:80}
		        ]],
		onClickRow:function(row){
			save();
			edit(row);
		},
   });
});

var editingId;
function edit(row){
    if (row){
    	editingId = row.id;
        $('#tarento').treegrid('beginEdit', editingId);
    }
}
function save(){
    if (editingId != undefined){
        var t = $('#tarento');
        t.treegrid('endEdit', editingId);
        editingId = undefined;
        var persons = 0;
        var rows = t.treegrid('getChanges','updated');
        for(var i=0; i<rows.length; i++){
            var p = parseInt(rows[i].persons);
            if (!isNaN(p)){
                persons += p;
            }
	        $.post('<{$config.weburl}>/admin/module.php?m=product&s=tarento_list.php&act=saveInfo',{data:rows[i]},function(res){
	        	if(res.code>0){
	        		alert(res.msg);
	        	}
	        });
        }
        var frow = t.treegrid('getFooterRows')[0];
        frow.persons = persons;
        t.treegrid('reloadFooter');
    }
}
</script>
</head>
<body>
<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>合伙人列表</h3>
            </div>
        </div>
        
        <div class="h35"></div>
        
        <form action="" method="get">
        <input type="hidden" name="m" value="product">
        <input type="hidden" name="s" value="tarento_list.php">
        <table class="select_table">
            <tbody>
                <tr>
                    <td width="60">用户ID:</td>
                    <td width="100"><input id="member_id" type="text" name="member_id" class="w100" value="<{$smarty.get.member_id}>" /></td>
                    <td><input id="search" type="image" src="<{$config.weburl}>/image/admin/search.gif" /></td>
                </tr>
                
            </tbody>
        </table>
        </form>
        <table id="tarento" class="easyui-treegrid" style="width:100%">
        </table>
</div>
</body>
<script>
$(".a-opear").live('click',function(){
    
    var data = $(this).attr('data-param');
    eval("data = "+data);
    var type = $(this).attr('data-type');
    if(!data.id)
    {
        error('error','对不起，请选择一个合伙人后操作！');
        return false;
    }
    
    if(type=='edit_rate'){
        window.parent.iframe_form("edit_rate", '设置最低返利比例', '<{$config.weburl}>/admin/module.php?m=product&s=tarento_rate_setting.php&id='+data.id, 500,300);
        return false;
    }

    return false;
    
});
</script>
</html>